<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.leanModal.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<title>Untitled Document</title>
<script>
	$(function() {

		$( "#date_begin" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		$( "#date_end" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		$(".datepick").datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		
	});
	function checkPassword(){
		var password = 	$('#password').attr('value');
		if(password == 'Office051788'){
			$('#step2').css("display","block");
			$('#admin').css("display","none");
		}
	}

</script>
<style type="text/css">
#step2{
	display:none;
}
</style>
</head>

<body >
<form id = "form1" action="" method="post">

<div style="font-family:Arial, Helvetica, sans-serif" >
<?php $repairJob = new Model_DbTable_Repairjob(Zend_Registry::get('db_remoteapp'));?>
<?php if(empty($this->link)){?>
<h2>Alex Bonus Step 1 (Choose Period)</h2>
Date Start:<input type = "text" name = "date_begin" id = "date_begin" value = "<?php if(!empty($this->dateBegin)){ echo $this->dateBegin;}?>"></input>
Date End:<input type = "text" name = "date_end" id = "date_end" value = "<?php if(!empty($this->dateEnd)){ echo $this->dateEnd;}?>"></input>

<input type = "submit" name = "submit" value = "submit"></input>
<br/><br/>

<?php if(!empty($this->arrRes)){?>

<h1>Everything OK (<?php echo count($this->arrRes)?>)</h1>
<table width="1300" border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th scope="col">ID</th>
    <th scope="col">Rb</th>
    <th scope="col">Model</th>
    <th scope="col">Repair Type</th>
    <th scope="col">Charge</th>
    <th scope="col">Invoice</th>
    <th scope="col">Invoice Charge (System)</th>
    <th scope="col">Parts</th>
    <th scope="col">Parts Qty</th>
    <th scope="col">Parts Cost</th>
  </tr>
  <?php $okChargeTotal = 0;
  		$okCostTotal = 0;
  		?>
  <?php foreach($this->arrRes as $key => $v){?>
  <tr>
    <td><?php echo $v[0]?><input type ="hidden" name = "id_job[<?php echo $v[0]?>]" value = "<?php echo $v[0]?>"></input></td>
    <td><?php echo $v[10]?><input type ="hidden" name = "repair_by[<?php echo $v[0]?>]" value = "<?php echo $v[10];?>"></input></td>
    <td><?php echo $v[1]?><input type ="hidden" name = "model[<?php echo $v[0]?>]" value = "<?php echo $v[1];?>"></input></td>
    <td><?php echo $v[3]?><input type ="hidden" name = "repair_type[<?php echo $v[0]?>]" value = "<?php echo $v[3];?>"></input></td>
    <td><?php echo $v[5]?><?php $okChargeTotal += $v[5];?><input type ="hidden" name = "charge[<?php echo $v[0]?>]" value = "<?php echo $v[5];?>"></input></td>
    <td><?php echo $v[6][0],$v[6][1];?><input type ="hidden" name = "inv1[<?php echo $v[0]?>]" value = "<?php echo $v[6][0];?>"></input><input type ="hidden" name = "inv2[<?php echo $v[0]?>]" value = "<?php echo $v[6][1];?>"></input></td>
    <td 
    <?php if( $v[5] != $v[8] ) {?>
    style="background-color:#FFA4A4;"
    <?php }?>
    ><?php echo $v[8]?><input type ="hidden" name = "charge_sys[<?php echo $v[0]?>]" value = "<?php echo $v[8];?>"></input></td>
    <td><?php
    foreach($v[7] as $lineItem){
		echo  $lineItem[0].' x '.$lineItem[3].' ['.$lineItem[1].']'."<br/>"; ?>
		<input type ="hidden" name = "parts[<?php echo $v[0]?>][<?php echo $lineItem[0]?>]" value = "<?php echo $lineItem[3];?>"></input>
	<?php 	
		if($lineItem[4]!='-'){
			echo " Borrow:".$lineItem[4].' '.$lineItem[5];
			}
		echo '<br />';
		}
	?></td>
	<td><?php echo $v[11]?><input type ="hidden" name = "parts_qty[<?php echo $v[0]?>]" value = "<?php echo $v[11];?>"></input></td>
    <td 
    <?php if($v[9] >= 10000) {?>
     style="background-color:#FFA4A4;"
	<?php }?>
    ><?php $count = count($v[7])-1;
    if($count == 0){
    	echo $v[9];
	}else{?>
    <?php for($i = 0;$i<=$count;$i++){
    	?>
    	<input type ="hidden" name = "sep_parts[<?php echo $v[0]?>][]" value = "<?php echo $v[7][$i][3]*$v[7][$i][2];?>"></input>
    	<?php 
    		if($i != $count){
    			if($v[7][$i][3]*$v[7][$i][2] >=0){
    				echo $v[7][$i][3]*$v[7][$i][2]."+";
    			}else{
    				echo "(".$v[7][$i][3]*$v[7][$i][2].")"." +";
    			}
    		}else{
    			if($v[7][$i][3]*$v[7][$i][2] >=0){
    				echo $v[7][$i][3]*$v[7][$i][2];
    			}else{
    				echo "(".$v[7][$i][3]*$v[7][$i][2].")";
    			}
    		}
		   }
	?><?php echo "=".$v[9];
	}?><input type ="hidden" name = "cost[<?php echo $v[0]?>]" value = "<?php echo $v[9];?>"></input></td>
	<?php $okCostTotal += $v[9];?>
  </tr>
  <?php ?>
 <?php }?>
 <tr>
 	<td colspan = "4">&nbsp;</td>
 	<td><?php echo "Total: ".$okChargeTotal;?></td>
 	<td colspan = "4">&nbsp;</td>
 	<td><?php echo "Total: ".$okCostTotal;?></td>
 </tr>
</table>
<?php }?>

<?php if(!empty($this->checkList)){?>
<h1>Need Check List(<?php echo count($this->checkList)?>)</h1>
<?php 	$checkChargeTotal = 0;
  		?>
<table width="1500" border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th scope="col">ID</th>
    <th scope="col">Rb</th>
    <th scope="col">Model</th>
    <th scope="col">Repair Type</th>
    <th scope="col">Charge</th>
    <th scope="col">Invoice</th>
    <th scope="col" width = "30px">Invoice Charge (System)</th>
    <th scope="col">Parts</th>
    <th scope="col">Parts Qty</th>
    <th scope="col">Parts Cost Total</th>
  </tr>
  <?php foreach($this->checkList as $key => $v){
  			$totalCharge = 0;
  			$totalChargeApos = 0;
  			$totalCost = 0;
  			$totalQty = 0;
  ?>
  <tr>
    <td><?php foreach($v as $k2 => $v2){
    	$rDetail = $repairJob->getJob($v2[0]);
    	echo $v2[0]."<br/>"; ?>
    	<input type ="hidden" name = "check_id_job[<?php echo $v2[0]?>]" value = "<?php echo $v2[0]?>"></input>
	<?php }?></td>
    <td><?php 
    	 echo $v[0][10];
    	 ?><?php foreach ($v as $k2 => $v2){?>
    	 <input type ="hidden" name = "check_repair_by[<?php echo $v2[0]?>]" value = "<?php echo $v[0][10];?>"></input>
    	 <?php }?></td>
    <td><?php foreach($v as $k2 => $v2){
    	echo $v2[1]."<br/>"; ?>
    	<input type ="hidden" name = "check_model[<?php echo $v2[0]?>]" value = "<?php echo $v2[1];?>"></input>
   <?php }?></td>
    <td><?php foreach($v as $k2 => $v2){
    	echo $v2[3]."<br/>"; ?>
    	<input type ="hidden" name = "check_repair_type[<?php echo $v2[0]?>]" value = "<?php echo $v2[3];?>"></input>
	<?php }?></td>
    <td><?php foreach($v as $k2 => $v2){
    		$totalCharge += $v2[5];
	}?><?php echo $totalCharge;?><?php foreach ($v as $k2 => $v2){?><input type ="hidden" name = "check_charge[<?php echo $v2[0]?>]" value = "<?php echo $totalCharge;;?>"></input><?php }?>
	<?php $checkChargeTotal += $totalCharge;?></td>
    <td><?php echo $key."(".$rDetail['shop_code']." )";?><?php foreach($v as $k2 => $v2){?><input type ="hidden" name = "check_inv1[<?php echo $v2[0]?>]" value = "<?php echo $key;?>"></input><?php }?></td>
    <td 
    <?php foreach($v as $k2 => $v2){
    		$totalChargeApos = $v2[8];?>
	<?php }?>
    <?php if( $totalCharge != $totalChargeApos ) {?>
    style="background-color:#FFA4A4;"
    <?php }?>
    ><?php echo $totalChargeApos;?><?php foreach ($v as $k2 => $v2){?><input type ="hidden" name = "check_charge_sys[<?php echo $v2[0]?>]" value = "<?php echo $totalChargeApos;?>"></input><?php }?></td>
    <td><?php
    foreach($v as $k2 => $v2){
    	foreach($v2[7] as $lineItem){
			echo  $lineItem[0].' x '.$lineItem[3].' ['.$lineItem[1].']'."<br/>";?>
			<input type ="hidden" name = "check_parts[<?php echo $v2[0]?>][<?php echo $lineItem[0]?>]" value = "<?php echo $lineItem[3];?>"></input>
			<?php 
			if($lineItem[4]!='-'){
				echo " Borrow:".$lineItem[4].' '.$lineItem[5];
				}
			}
    }
	?></td>
	<td><?php foreach($v as $k2 => $v2){
    		$totalQty += $v2[11];
	}?><?php echo $totalQty;?><?php foreach($v as $k2 => $v2){?><input type ="hidden" name = "check_parts_qty[<?php echo $v2[0]?>]" value = "<?php echo $totalQty;?>"></input><?php }?></td>
    <td 
    
    <?php 
    foreach($v as $k2 => $v2){
   		 if($v2[9] >= 10000) {?>
    		 style="background-color:#FFA4A4;"
	<?php }
    }?>
    ><?php 
    foreach($v as $k2 => $v2){
   	 	$count = count($v2[7])-1;
 		for($i = 0;$i<=$count;$i++){ ?>
 			<input type ="hidden" name = "check_sep_parts[<?php echo $v2[0]?>][]" value = "<?php echo $v2[7][$i][3]*$v2[7][$i][2];?>"></input>
 		<?php 
    		if($i != $count){
    			echo $v2[7][$i][3]*$v2[7][$i][2]."+";
    		}else{
    			echo $v2[7][$i][3]*$v2[7][$i][2]."+";
    		}
		}
		$totalCost += $v2[9];
    }
	?><?php echo "=".$totalCost?><?php foreach($v as $k2 => $v2){?><input type ="hidden" name = "check_cost[<?php echo $v2[0]?>]" value = "<?php echo $totalCost;?>"></input><?php }?>
	</td>
  </tr>
  
 <?php }?>
</table>
<?php }?>


<?php if(!empty($this->arrProblems)){?>
<h1>Problems (<?php echo count($this->arrProblems)?>)</h1>
<table width="1300" border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th scope="col">ID</th>
    <th scope="col">Rb</th>
    <th scope="col">Model</th>
    <th scope="col">Repair Type</th>
    <th scope="col">Charge</th>
    <th scope="col">Invoice</th>
    <th scope="col">Invoice Charge (System)</th>
    <th scope="col">Parts</th>
    <th scope="col">Parts Qty</th>
    <th scope="col">Parts Cost Total</th>
  </tr>
  <?php foreach($this->arrProblems as $key => $v){
  		$rDetail = $repairJob->getJob($v[0]);?>
  <tr>
    <td><?php echo $v[0]?><input type ="hidden" name = "pb_id_job[<?php echo $v[0]?>]" value = "<?php echo $v[0]?>"></input></td>
    <td><?php echo $v[10]?><input type ="hidden" name = "pb_repair_by[<?php echo $v[0]?>]" value = "<?php echo $v[10];?>"></input></td>
    <td><?php echo $v[1]?><input type ="hidden" name = "pb_model[<?php echo $v[0]?>]" value = "<?php echo $v[1];?>"></input></td>
    <td><?php echo $v[3]?><input type ="hidden" name = "pb_repair_type[<?php echo $v[0]?>]" value = "<?php echo $v[3];?>"></input></td>
    <td><?php echo $v[5]?><?php $okChargeTotal += $v[5];?><input type ="hidden" name = "pb_charge[<?php echo $v[0]?>]" value = "<?php echo $v[5];?>"></input></td>
    <td><?php echo $v[6][0]." ".$v[6][1]." (".$rDetail['shop_code']." ) ";?><input type ="hidden" name = "pb_inv1[<?php echo $v[0]?>]" value = "<?php echo $v[6][0];?>"></input><input type ="hidden" name = "pb_inv2[<?php echo $v[0]?>]" value = "<?php echo $v[6][1];?>"></input></td>
    <td 
    <?php if( $v[5] != $v[8] ) {?>
    style="background-color:#FFA4A4;"
    <?php }?>
    ><?php echo $v[8]?><input type ="hidden" name = "pb_charge_sys[<?php echo $v[0]?>]" value = "<?php echo $v[8];?>"></input></td>
    <td><?php
    foreach($v[7] as $lineItem){
		echo  $lineItem[0].' x '.$lineItem[3].' ['.$lineItem[1].']'."<br/>"; ?>
		<input type ="hidden" name = "pb_parts[<?php echo $v[0]?>][<?php echo $lineItem[0]?>]" value = "<?php echo $lineItem[3];?>"></input>
		<?php 
		if($lineItem[4]!='-'){
			echo " Borrow:".$lineItem[4].' '.$lineItem[5];
			}
		}
	?></td>
	<td><?php echo $v[11]?><input type ="hidden" name = "pb_parts_qty[<?php echo $v[0]?>]" value = "<?php echo $v[11];?>"></input></td>
      <td 
    <?php if($v[9] >= 10000) {?>
     style="background-color:#FFA4A4;"
	<?php }?>
    ><?php $count = count($v[7])-1;
    if($count == 0){
    	echo $v[9];
	}else{?>
    <?php for($i = 0;$i<=$count;$i++){?>
    	<input type ="hidden" name = "pb_sep_parts[<?php echo $v[0]?>][]" value = "<?php echo $v[7][$i][3]*$v[7][$i][2];?>"></input>
    <?php 	
    		if($i != $count){
    			if($v[7][$i][3]*$v[7][$i][2] >=0){
    				echo $v[7][$i][3]*$v[7][$i][2]."+";
    			}else{
    				echo "(".$v[7][$i][3]*$v[7][$i][2].")"." +";
    			}
    		}else{
    			if($v[7][$i][3]*$v[7][$i][2] >=0){
    				echo $v[7][$i][3]*$v[7][$i][2];
    			}else{
    				echo "(".$v[7][$i][3]*$v[7][$i][2].")";
    			}
    		}
		   }
	?><?php echo "=".$v[9];
	}?><input type ="hidden" name = "pb_cost[<?php echo $v[0]?>]" value = "<?php echo $v[9];?>"></input></td>
  </tr>
  
 <?php }?>
</table>
<?php }?>
</div>
<br/><br/>
<?php }?>

<?php $rProduct = new Model_DbTable_Pr_Prproducts(Zend_Registry::get('db_remoteapp'));
	  $shopList = unserialize(ARR_RCENTER_REV_MAPPING);
	  $staffDetail = new Model_DbTable_Roster_Stafflogindetail(Zend_Registry::get('db_remoteapp'));
	  $rJob = new Model_DbTable_Repairjob(Zend_Registry::get('db_remoteapp'));
?>
<?php if(!empty($this->orderList)){?>
<h3>Alex Order Parts List</h3>
	<table width="500" border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>Barcode</th>
			<th>Title</th>
			<th>Qty</th>
			<th>Cost(IC GST)</th>
			<th>Total Cost(IC GST)</th>
			<th>Date Order</th>
		</tr>
		<?php if ($this->orderList){
			$total = 0;
		?>
		<?php foreach($this->orderList as $k => $v){
			$partsTCost = 0;
			$rDetail = $rProduct->getProduct($v['id_product']);
		?>
		<?php if($rDetail['price_t']){?>
		<tr>
			
			<td><?php echo $rDetail['code_product']?><?php echo ($rDetail['active'])?'':'[X]';?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v['qty_product']?></td>
			<td><?php $costParts = $rDetail['price_t']*1.1;
					  $partsTCost = $costParts*$v['qty_product'];
					  $total += $costParts*$v['qty_product'];
					  if($rDetail['price_t'] == 0){
							echo "<span style = \"color:red\">" + $costParts + "</span>";	
					  }else{
							echo $costParts;
					  }
					?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v['date_move']?></td>
			
		</tr>
		<?php }?>
		<?php }?>
		<?php foreach($this->orderList as $k => $v){
			$partsTCost = 0;
			$rDetail = $rProduct->getProduct($v['id_product']);
		?>
		<?php if(!$rDetail['price_t']){?>
		<tr>	
			<td><?php echo $rDetail['code_product']?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v['qty_product']?></td>
			<td><?php echo "<span style = \"color:red\">Null Cost</span>";?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v['date_move']?></td>
		</tr>
		<?php }?>
		<?php }?>

		<tr>
			<td colspan = "6">Total Cost:$<?php echo $total?>
			<input type = "hidden" name = "orderList" value = "<?php echo $total;?>" ></input></td>
		</tr>
		<?php }?>
	</table>
	<h3>Alex Borrow In List</h3>
	<table width="900" border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>Barcode</th>
			<th>Title</th>
			<th>Qty</th>
			<th>Cost(IC GST)</th>
			<th>Total Cost(IC GST)</th>
			<th>Borrow In Date</th>
			<th>Job Id</th>
			<th>Borrow From</th>
			<th>Apply Staff</th>
			<th>Confirm Staff</th>
		</tr>
		<?php if ($this->alexIn){
			$total2 = 0;
		?>
		<?php foreach($this->alexIn as $k2 => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			if($v2['id_staff']){
				$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			}else{
				$appstaffNi['ni'] = 'Null';
			}
			if($v2['id_staff']){
				$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
			}else{
				$confstaffNi['ni'] = 'Null';
			}
		?>
		<?php if($rDetail['price_t']){?>
		<tr>
			
			<td><?php echo $rDetail['code_product']?><?php echo ($rDetail['active'])?'':'[X]';?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php $costParts2 = $rDetail['price_t']*1.1;
					  $partsTCost2 = $costParts2*$v2['qty_product'];
					  $total2 += $costParts2*$v2['qty_product'];
					  if($rDetail['price_t'] == 0){
							echo "<span style = \"color:red\">" + $costParts2 + "</span>";	
					  }else{
							echo $costParts2;
					  }
					?></td>
			<td><?php echo $partsTCost2;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_from']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
			
		</tr>
		<?php }?>
		<?php }?>
		<?php foreach($this->alexIn as $k => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			
			
			if($v2['id_staff']){
				$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			}else{
				$appstaffNi['ni'] = 'Null';
			}
			if($v2['id_staff']){
				$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
			}else{
				$confstaffNi['ni'] = 'Null';
			}
		?>
		<?php if(!$rDetail['price_t']){?>
		<tr>	
			<td><?php echo $rDetail['code_product']?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php echo "<span style = \"color:red\">Null Cost</span>";?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_from']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
		</tr>
		<?php }?>
		<?php }?>

		<tr>
			<td colspan = "10">Total Cost:$<?php echo $total2?>
			<input type = "hidden" name = "borrowIn" value = "<?php echo $total2;?>" ></input></td>
		</tr>
		<?php }?>
	</table>	
	<h3>Alex Borrow Out List( Not Repair by alex )</h3>
	<table width="900" border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>Barcode</th>
			<th>Title</th>
			<th>Qty</th>
			<th>Cost(IC GST)</th>
			<th>Total Cost(IC GST)</th>
			<th>Borrow Out Date</th>
			<th>Job Id</th>
			<th>Borrow to Shop</th>
			<th>Apply Staff</th>
			<th>Confirm Staff</th>
			<th>Fix By</th>
		</tr>
		<?php if ($this->alexOut){
			$total3 = 0;
		?>
		<?php foreach($this->alexOut as $k2 => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			if($v2['id_staff']){
				$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			}else{
				$appstaffNi['ni'] = 'Null';
			}
			if($v2['id_staff']){
				$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
			}else{
				$confstaffNi['ni'] = 'Null';
			}
			$jobDetail = $rJob->getJob($v2['id_job']);
			$staff = $staffDetail->getDetail($jobDetail['repair_staff']);
		?>
		<?php if($rDetail['price_t']){?>
		<tr>
			
			<td><?php echo $rDetail['code_product']?><?php echo ($rDetail['active'])?'':'[X]';?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php $costParts2 = $rDetail['price_t']*1.1;
					  $partsTCost2 = $costParts2*$v2['qty_product'];
					  $total3 += $costParts2*$v2['qty_product'];
					  if($rDetail['price_t'] == 0){
							echo "<span style = \"color:red\">" + $costParts2 + "</span>";	
					  }else{
							echo $costParts2;
					  }
					?></td>
			<td><?php echo $partsTCost2;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_to']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
			<td><?php echo $staff['ni']?></td>
			
		</tr>
		<?php }?>
		<?php }?>
		<?php foreach($this->alexOut as $k => $v2){
			$partsTCost2 = 0;
			$rDetail = $rProduct->getProduct($v2['id_product']);
			if($v2['id_staff']){
				$appstaffNi = $staffDetail->getDetail($v2['id_staff']);
			}else{
				$appstaffNi['ni'] = 'Null';
			}
			if($v2['id_staff']){
				$confstaffNi = $staffDetail->getDetail($v2['id_staff_confirm']);
			}else{
				$confstaffNi['ni'] = 'Null';
			}
			$jobDetail = $rJob->getJob($v2['id_job']);
			$staff = $staffDetail->getDetail($jobDetail['repair_staff']);
		?>
		<?php if(!$rDetail['price_t']){?>
		<tr>	
			<td><?php echo $rDetail['code_product']?></td>
			<td><?php echo $rDetail['title_product']?></td>
			<td><?php echo $v2['qty_product']?></td>
			<td><?php echo "<span style = \"color:red\">Null Cost</span>";?></td>
			<td><?php echo $partsTCost;?></td>		
			<td><?php echo $v2['date_loan']?></td>
			<td><?php echo $v2['id_job']?></td>
			<td><?php echo $shopList[$v2['shop_to']]?></td>
			<td><?php echo $appstaffNi['ni']?></td>
			<td><?php echo $confstaffNi['ni']?></td>
			<td><?php echo $staff['ni']?></td>
		</tr>
		<?php }?>
		<?php }?>

		<tr>
			<td colspan = "11">Total Cost:$<?php echo $total3?>
			<input type = "hidden" name = "borrowOut" value = "<?php echo $total3;?>" ></input></td>
		</tr>
		<?php }?>
	</table>
	<br/><br/>
	
		<input type = "submit" name = "export" id = "export" value = "Download for check"></input><br/><br/>

		<?php }?>
</form>
		

<div id = "step2">
<form id = "form2" action="/repairparts/alex-invoice" method="post" enctype="multipart/form-data">
<?php if($this->link){echo $this->link."<br/><br/><br/>"; }?>
	<h2>Alex Bonus Step 2(Upload calculatd total charge/cost file)</h2>
    Date Begin <input type = "text" name = "dateBegin" class = "datepick" />
    Date End <input type = "text" name = "dateEnd"   class = "datepick" />
    <table>
	<tr>
    	<td>Input Return To WH AD No.</td>
        <td><input type = "text" name = "returnAdNo"  size = "10" /></td>
    </tr>
</table>
    
	<input name = "file" id = "file" type="file"></input>
	<input type = "submit" name = "input" id = "input" value = "Submit & Next"></input><br/><br/>
</form>

<a href = "http://<?php echo SERVER_IP_COMM;?>/repairparts/alex-invoice" target="_blank" >Jump To Step 3</a>
</div>
<div id = "admin">
<h3>For Admin</h3>
Input password:<input type = "password" id = "password"  />
<input type = "submit" id = "checkPassword" onclick = "checkPassword()"/>
</div>
</body>
</html>
